home *** CD-ROM | disk | FTP | other *** search
/ Champak 54 / Vol 54.iso / games / turttleo.swf / scripts / DefineSprite_787 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-10-01  |  2.7 KB  |  63 lines

  1. var this_width = 400;
  2. var this_height = 300;
  3. var halved_koof = 10;
  4. var halved_width = this_width / halved_koof;
  5. var halved_height = this_height / halved_koof;
  6. var damper = new flash.display.BitmapData(halved_width,halved_height,false,128);
  7. var result = new flash.display.BitmapData(halved_width,halved_height,false,128);
  8. var result2 = new flash.display.BitmapData(this_width,this_height,false,128);
  9. var source = new flash.display.BitmapData(halved_width,halved_height,false,128);
  10. var buffer = new flash.display.BitmapData(halved_width,halved_height,false,128);
  11. var output = new flash.display.BitmapData(this_width,this_height,true,128);
  12. var surface = flash.display.BitmapData.loadBitmap("surface");
  13. var bounds = new flash.geom.Rectangle(0,0,halved_width,halved_height);
  14. var origin = new flash.geom.Point();
  15. var matrix = new flash.geom.Matrix();
  16. var matrix2 = new flash.geom.Matrix();
  17. matrix2.a = matrix2.d = halved_koof;
  18. var wave = new flash.filters.ConvolutionFilter(3,3,[1,1,1,1,1,1,1,1,1],9,0);
  19. var damp = new flash.geom.ColorTransform(0,0,0.9960937,1,0,0,2,0);
  20. var water = new flash.filters.DisplacementMapFilter(result2,origin,4,4,32,32,"ignore");
  21. this.attachBitmap(output,0);
  22. var ms = getTimer();
  23. var frame = 0;
  24. var mouseDown = false;
  25. this.onMouseUp = function()
  26. {
  27.    var _loc1_ = _xmouse / halved_koof;
  28.    var _loc2_ = _ymouse / halved_koof;
  29.    source.setPixel(_loc1_ + 1,_loc2_,16777215);
  30.    source.setPixel(_loc1_ - 1,_loc2_,16777215);
  31.    source.setPixel(_loc1_,_loc2_ + 1,16777215);
  32.    source.setPixel(_loc1_,_loc2_ - 1,16777215);
  33.    source.setPixel(_loc1_,_loc2_,16777215);
  34. };
  35. var _loc2 = halved_width * Math.random();
  36. var _loc1 = halved_height * Math.random();
  37. source.setPixel(_loc2 + 1,_loc1,16777215);
  38. source.setPixel(_loc2 - 1,_loc1,16777215);
  39. source.setPixel(_loc2,_loc1 + 1,16777215);
  40. source.setPixel(_loc2,_loc1 - 1,16777215);
  41. source.setPixel(_loc2,_loc1,16777215);
  42. this.onEnterFrame = function()
  43. {
  44.    if(Math.random() > 0.999)
  45.    {
  46.       var _loc1_ = halved_width * Math.random();
  47.       var _loc2_ = halved_height * Math.random();
  48.       source.setPixel(_loc1_ + 1,_loc2_,16777215);
  49.       source.setPixel(_loc1_ - 1,_loc2_,16777215);
  50.       source.setPixel(_loc1_,_loc2_ + 1,16777215);
  51.       source.setPixel(_loc1_,_loc2_ - 1,16777215);
  52.       source.setPixel(_loc1_,_loc2_,16777215);
  53.    }
  54.    result.applyFilter(source,bounds,origin,wave);
  55.    result.draw(result,matrix,null,"add");
  56.    result.draw(buffer,matrix,null,"difference");
  57.    result.draw(result,matrix,damp);
  58.    result2.draw(result,matrix2,null,null,null,true);
  59.    output.applyFilter(surface,new flash.geom.Rectangle(0,0,this_width,this_height),origin,water);
  60.    buffer = source;
  61.    source = result.clone();
  62. };
  63.